import { HttpException, HttpStatus, ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { LoginGuard } from './guard/login.guard';
import { XjwtService } from './xjwt/xjwt.service';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  
  const xjwtService = app.get(XjwtService)
  const configService = app.get(ConfigService)

  const routePrefix = configService.get('routePrefix')
  if(routePrefix) {
    app.setGlobalPrefix(routePrefix)
  }

  app.useGlobalGuards(new LoginGuard(configService, xjwtService))
  await app.listen(3002);
}
bootstrap();
